package models

import (
	"gorm.io/gorm"
	"time"
)

// 秒杀订单表
type SeckillActivity struct {
	Id           uint64    `gorm:"column:id;type:bigint UNSIGNED;comment:秒杀订单表;primaryKey;not null;" json:"id"` // 秒杀订单表
	OrderNo      string    `gorm:"column:order_no;type:varchar(255);default:NULL;" json:"order_no"`
	UserId       int32     `gorm:"column:user_id;type:int;default:NULL;" json:"user_id"`
	GoodsId      int32     `gorm:"column:goods_id;type:int;default:NULL;" json:"goods_id"`
	SeckillPrice string    `gorm:"column:seckill_price;type:varchar(255);default:NULL;" json:"seckill_price"`
	Num          int32     `gorm:"column:num;type:int;default:NULL;" json:"num"`
	CreatedAt    time.Time `gorm:"column:created_at;type:datetime(3);default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt    time.Time `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt    time.Time `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (s *SeckillActivity) TableName() string {
	return "seckill_activity"
}
func (s *SeckillActivity) CreateSeckillActivity(tx *gorm.DB) error {
	return tx.Create(s).Error
}
